<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
$return=array();
if($_RQ['op']=='edit'){
	$return['item']=$this->plugin_setting('secury');
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'参数设置',
		'edit_tab' =>'参数设置',
		'edits'=>array(
			array('title' => '防伪码生成设置',
				'list' => array(
				array('type'=>'tip','title'=>'[温馨提示]：如果已经生成了已经添加了防伪商品，添加防伪批次，请勿修改本：防伪码生成设置。否则可能导致，已生成的批次不可用！'),
				array('name'=>'pre','title'=>'防伪码前缀','type'=>'string','help'=>'例如 FW'),
				array('name'=>'goods','title'=>'商品编号位数','type'=>'radio','options'=>'num','help'=>'不填默认10位'),
				array('name'=>'batch','title'=>'批号位数','type'=>'radio','options'=>'num','help'=>'不填默认10位'),
				array('name'=>'serial','title'=>'流水号位数','type'=>'string','type'=>'radio','options'=>'num','help'=>'不填默认10位'),
				array('name'=>'code','title'=>'校验码位数','type'=>'string','help'=>'建议10位以内'),	
				array('name'=>'garble','title'=>'混淆码位数','type'=>'string','help'=>'建议5位以内'),
				array('name'=>'num','title'=>'查询次数限制','type'=>'string','help'=>'限制每个防伪码允许查询次数，0表示不限制'),
			),
		))
	);
	$return['num']=array('4'=>'4位','6'=>'6位','8'=>'8位','10'=>'10位');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if($postdata['code']>32){
		exi('校验码位数不能大于32','error');
	}
	if($postdata['garble']>32){
		exi('混淆码位数不能大于32','error');
	}
	$data=array_fields(array('pre','goods','batch','serial','code','garble','num'),$postdata);
	$this->plugin_setting('secury',$data);
	exi('设置成功');
}
?>